<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
  <link rel="stylesheet" href="../../plugins/font-awesome/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="../../https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="../../dist/css/adminlte.min.css">
	</head>
	<!-- jQuery -->
<script src="../../plugins/jquery/jquery.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
/*  $.widget.bridge('uibutton', $.ui.button)
*/</script>
<!-- Bootstrap 4 -->
<script src="../../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Morris.js charts -->

<!-- Bootstrap WYSIHTML5 -->
<script src="../../plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<!-- Slimscroll -->
<!-- AdminLTE App -->
<script src="../../dist/js/adminlte.js"></script>
<script src="../../js/login.js"></script>
<script src="../../js/jquery.cookie.js"></script>
<body>
		

             
             
             
             
             <div id="selecta" style="display: none;">
             <label>装运形式</label>
                    <select id="theshippingform" class="form-control">
                     <option>请选择</option>
			         <option>飞机</option>
			         <option>火车</option>
			         <option>手搬</option>
                    </select>
                </div>
	<button id="xzrk" class="btn btn-danger" disabled="disabled">选中出库</button>	
		<table id="tab" width="100%" class="table table-bordered table-striped">
			<tr>
			<td><input type="checkbox" name="selectall" />选中入库</td>
	    <td>编号</td>
     	<td>出发日期</td>
     	<td>目的地</td>
     	<td>总价</td>
     	<td>寄件人</td>
     	<td>收件人</td>
     	<td>类型</td>
     	<td>是否可被签收？</td>
     	<td>是否被审核</td>
        <td>是否被签收</td>
        <td>操作</td>
			</tr>
			
			
			
		</table>
	
		
	</body>
	<script>
		
		   $('input[name="selectall"]').click(function(){ 
             if($(this).is(':checked')){ 
             	$("#xzrk").attr("disabled",false);
                $('input[name="storage"]').each(function(){  
                    //此处如果用attr，会出现第三次失效的情况  
                    $(this).prop("checked",true);  
                });  
        }else{  
        	$("#xzrk").attr("disabled",true);
            $('input[name="storage"]').each(function(){  
                    $(this).prop("checked",false);  
                });  
                //$(this).removeAttr("checked");  
        } 
    });  
   
	var zz=[];
	var zc=[];
	 var now = new Date();  
          
        var year = now.getFullYear();       //年  
        var month = now.getMonth() + 1;     //月  
        var day = now.getDate();            //日  
          
        var hh = now.getHours();            //时  
        var mm = now.getMinutes();          //分  
        var ss = now.getSeconds();           //秒  
          
        var clock = year + "-";  
          
        if(month < 10)  
            clock += "0";  
          
        clock += month + "-";  
          
        if(day < 10)  
            clock += "0";  
              
        clock += day + " ";  
          
        if(hh < 10)  
            clock += "0";  
              
        clock += hh + ":";  
        if (mm < 10) clock += '0';   
        clock += mm + ":";   
           
        if (ss < 10) clock += '0';   
        clock += ss;   
		
		/*中转单出库*/
		function removalzz(i){
			$("#selecta").show();
		   var sasid= zz[i].sendasingle.sasid;
		   var destination=  zz[i].sendasingle.cargoinformation;
		   var tosid= zz[i].transitofsingle.tosid;
		   if($("#theshippingform").val()=="请选择"){
		   	 alert("请选择装运形式");
		   	 throw SyntaxError();
		   }
		   
		   $.ajax({
			     type: "post", //请求方式
				 async: true, //是否异步
				 xhrFields:{withCredent: true},
	             crossDomain: true,
	             data:{"sid":$.cookie("sid"),"sasid":sasid,"destination":destination,"tosid":tosid,"outbounddeliverydate":clock,"theshippingform":$("#theshippingform").val()},
				 url: "http://localhost:8072/addzz",
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
				window.location.reload()
					 //请求成功处理，和本地回调完全一样
					
				},		
				 error: function() {
					 //请求出错处理					
				}	
		});
		       
		}
		/*装车单出库*/
		function removalzc(i){
			 $("#selecta").show();
		    var sasid= zc[i].sendasingle.sasid;
		   var destination=  zc[i].sendasingle.cargoinformation;
		   var tloid= zc[i].tloading.tloid;
		   if($("#theshippingform").val()=="请选择"){
		   	 alert("请选择装运形式");
		   	 throw SyntaxError();
		   }
		   
		   $.ajax({
			     type: "post", //请求方式
				 async: true, //是否异步
				 xhrFields:{withCredent: true},
	             crossDomain: true,
	             data:{"sid":$.cookie("sid"),"sasid":sasid,"destination":destination,"tloid":tloid,"outbounddeliverydate":clock,"theshippingform":$("#theshippingform").val()},
				 url: "http://localhost:8072/addzc",
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
				
         		window.location.reload()

					 //请求成功处理，和本地回调完全一样
					
				},		
				 error: function() {
					 //请求出错处理					
				}	
		});
		    
		    
		    
		  
		}
		
		
/*		$.ajax({
			    type: "post", //请求方式
				 async: true, //是否异步
				  xhrFields:{withCredent: true},
	             crossDomain: true,
	             data:{"sid":5},
				 url: "http://localhost:8072/Selecttruckandtransit",
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
				
				 	$.each(data.list, function(i,d) { 
				 		alert(d.sendasingle.sasid);
/*					  $("#tab").append("<tr><td>"+data[i].sendasingle.sasid+"</td></td><td>"+data[i].sendasingle.starting+"</td><td>"+data[i].sendasingle.cargoinformation+"</td><td>"+data[i].sendasingle.totalvalue+"</td><td>"+data[i].sendasingle.senderinformation+"</td><td>"+data[i].sendasingle.consigneeinformation+"</td><td>"+data[i].sendasingle.ordertype+"</td><td><span class='badge bg-success'>"+data[i].sendasingle.cansignforit+"<span></td><td><span class='badge bg-success'>"+data[i].sendasingle.isitreviewed+"</span></td><td><span class='badge bg-danger'>"+data[i].sendasingle.issignforit+"<span></td><td><button class='btn btn-success' onclick='removalzz("+i+")' >出库</button></td></tr>")                    
					 });
					 //请求成功处理，和本地回调完全一样
					
				},		
				 error: function() {
					 //请求出错处理
					
				}
           	
			
			
			
			
		});
		*/
		/*查询中转单*/
		$.ajax({
			    type: "post", //请求方式
				 async: true, //是否异步
				  xhrFields:{withCredent: true},
	             crossDomain: true,
	             data:{"sid":$.cookie("sid")},
				 url: "http://localhost:8072/Selecttransit",
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
				
				 	$.each(data, function(i,d) {    
					  $("#tab").append("<tr><input type='hidden' value='tosid:"+data[i].transitofsingle.tosid+"' /><td><input type='checkbox' name='storage' /></td><td>"+data[i].sendasingle.sasid+"</td></td><td>"+data[i].sendasingle.starting+"</td><td>"+data[i].sendasingle.cargoinformation+"</td><td>"+data[i].sendasingle.totalvalue+"</td><td>"+data[i].sendasingle.senderinformation+"</td><td>"+data[i].sendasingle.consigneeinformation+"</td><td>"+data[i].sendasingle.ordertype+"</td><td><span class='badge bg-success'>"+data[i].sendasingle.cansignforit+"<span></td><td><span class='badge bg-success'>"+data[i].sendasingle.isitreviewed+"</span></td><td><span class='badge bg-danger'>"+data[i].sendasingle.issignforit+"<span></td><td><button class='btn btn-success' onclick='removalzz("+i+")' >出库</button></td></tr>")
                       zz[i]=d;
					 });
					 //请求成功处理，和本地回调完全一样
					
				},		
				 error: function() {
					 //请求出错处理
					
				}
           	
			
			
		
			
		});
		/*查询装车*/
		$.ajax({
			    type: "post", //请求方式
				 async: true, //是否异步
				  xhrFields:{withCredent: true},
				  data:{"sid":$.cookie("sid")},
	             crossDomain: true,
				 url: "http://localhost:8072/Selecttruck",
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
				 	$.each(data, function(i,d) {    
				      zc[i]=d;
					  $("#tab").append("<tr><input type='hidden' value='tloid:"+data[i].tloading.tloid+"' /><td><input type='checkbox' name='storage' /></td><td>"+data[i].sendasingle.sasid+"</td></td><td>"+data[i].sendasingle.starting+"</td><td>"+data[i].sendasingle.cargoinformation+"</td><td>"+data[i].sendasingle.totalvalue+"</td><td>"+data[i].sendasingle.senderinformation+"</td><td>"+data[i].sendasingle.consigneeinformation+"</td><td>"+data[i].sendasingle.ordertype+"</td><td><span class='badge bg-success'>"+data[i].sendasingle.cansignforit+"<span></td><td><span class='badge bg-success'>"+data[i].sendasingle.isitreviewed+"</span></td><td><span class='badge bg-danger'>"+data[i].sendasingle.issignforit+"<span></td><td><button class='btn btn-success' onclick='removalzc("+i+")'>出库</button></td></tr>")
				 	 
					 });
					 //请求成功处理，和本地回调完全一样
					
				},		
				 error: function() {
					 //请求出错处理
					
				}
	
		});
		
		$("button:contains('选中')").on("click",function(){
			var arr=[];
			var i=0;
	    var check=$("input[name='storage']:checked");//选中的复选框
	     check.each(function(){
		 var row=$(this).parent("td").parent("tr");
	 	 var sasid=row.children().eq(2).text();//注意html()和val()   	  
		 arr[i]=sasid
		 i++;
	     });
	     
	     /*自动出库*/
	     $.ajax({
	            type: "post", //请求方式
				 async: true, //是否异步
				  xhrFields:{withCredent: true},
				  data:{"sid":$.cookie("sid"),"arr":arr},
				  traditional:true,
	             crossDomain: true,
				 url: "http://localhost:8072/chukuall",
				 dataType: "json", //跨域json请求一定是jsonp
				 // jsonp: "callback", //跨域请求的参数名，默认是callback
				 //jsonpCallback:"successCallback",    //自定义跨域参数值，回调函数名也是一样，默认为jQuery自动生成的字符串数
				beforeSend: function() {
					 //请求前的处理
					//alert("请求前")
				},success: function(data) {
				 	window.location.reload();
					 //请求成功处理，和本地回调完全一样
					
				},		
				 error: function() {
					 //请求出错处理
					
				}
	     	
	     	
	     	
	     	
	     })
			
			
			
		})
		
		
	</script>
	
</html>
